import java.util.Arrays;

public class erfenchazhao {
    public static int erfen(int[] a,int e){
        int n=a.length;
        int left=0;
        int right=n-1;

        while(right>left){
            int mid=(left+right)/2;
            if(e==a[mid]) {
                return mid;
            } else if (e>a[mid]) {
                left=mid+1;
            }else{
                right=mid-1;
            }
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] a={4,6,89,54,32,71,26,44,23,51,61,26,49,22,77};
        a=Arrays.stream(a).sorted().toArray();
        System.out.println(Arrays.toString(a));
        System.out.println(erfen(a, 77));
    }
}
